﻿namespace ProgrammingEducationSystem.Tools
{
    public class ApiResult
    {
        public int? Code { get; set; }
        public string? Message { get; set; }
        public Object? Data { get; set; }
        public bool Result { get; set; }


        public static ApiResult Success(string msg)
        {
            return new ApiResult()
            {
                Code = 200,
                Message = msg,
                Result = true
            };
        }
        public static ApiResult Success(Object data)
        {
            return new ApiResult()
            {
                Code = 200,
                Data = data,
                Result = true
            };
        }
        public static ApiResult Success(Object data,string msg)
        {
            return new ApiResult()
            {
                Code = 200,
                Message = msg,
                Data = data,
                Result = true
            };
        }
        public static ApiResult Failure( string msg) 
        {
            return new ApiResult()
            {
                Code = 400,
                Message = msg,
                Result = false
            };
        }

        public static ApiResult Failure(Object data)
        {
            return new ApiResult()
            {
                Code = 400,
                Data = data,
                Result = false
            };
        }

        public static ApiResult Failure(Object data, string msg)
        {
            return new ApiResult()
            {
                Code = 400,
                Message = msg,
                Data = data,
                Result = false
            };
        }
    }
}
